<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<style>
	  #fenlei_box{border: 1px solid #3297ff;position: absolute;width:450px;height:250px;overflow:hidden; z-index:9999;background:#fff;display:none;}
	  #fenlei_box li{list-style: none;color:#3297ff;text-align:left;margin-left:-20px;line-height: 32px;cursor: pointer;border-bottom:1px dashed}
	  #teshu{display: none;color:red;}
</style>
<div class="wrapper">
	<include file="Public/breadcrumb"/>
	<section class="content">
       <div class="row">
       		<div class="col-xs-12">
	       		<div class="box">
	             <div class="box-header">
	               	<nav class="navbar navbar-default">	     
				        <div class="collapse navbar-collapse">
				          <form class="navbar-form form-inline" action="{:U('Crm/visitList')}" method="get">
				            <div class="form-group">
				              	<input type="text" name="keywords" class="form-control" value="{:I('keywords')}" placeholder="请输入任务名称">
				            </div>
				            <div class="form-group">
				              	<input type="text" name="user_name" id="user_name" class="form-control" value="{:I('user_name')}" placeholder="请输入业务员名称/手机号码" oninput="user_sousuo($(this))" autocomplete="off">
				              	<ul id="fenlei_box">
                                </ul>
                                <input type="hidden" name="user_id" id="user_id" value="{:I('user_id')}"/>
				            </div>
				            <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="timegap" value="{$timegap}" placeholder="日期"  id="add_time" class="input-sm" style="width: 220px;">
					                 </div>
                                </div>
				            <button type="submit" class="btn btn-primary">查询</button>
				            <button type="button" style="margin-right:15%;" class="btn btn-default pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>	          
				            <div class="form-group pull-right">
					            <a href="{:U('Crm/addvisit')}" class="btn btn-primary pull-right"><i class="fa fa-plus"></i> 新增任务</a>
				            </div>	
				            
				          </form>
				      	</div>
	    			</nav>
	             </div>
	             <div class="box-body">
	           	 <div class="row">
	            	<div class="col-sm-12">
		              <table id="list-table" class="table table-bordered table-striped dataTable">
		                 <thead>
		                   <tr role="row">
                                           <th>任务id</th>
                                           <th>任务名称</th>
			                   <th>预计拜访时间</th>	
			                   <th>客户名称</th>	                   
			                   <th>拜访目的</th>
			                   <th>业务员</th>
			                   <th>业绩</th>
			                   <th>备注</th>
		                  	   <th>操作</th>
		                   </tr>
		                 </thead>
						<tbody>
                          <foreach name="list" item="vo" key="k" >
                             <tr role="row">    
                             <td>{$vo.id}</td>
		                     <td>{$vo.visit_name}</td>	                    
		                     <td>{$vo.visit_time}</td>
		                     <td>{$vo.custom_name}</td>
							 <td>{$vo.visit_purpose}</td>
							 <td>{$vo.user_id}</td>
							 <td>{$vo.total}元</td>
							 <td>{$vo.remark}</td>
		                     <td>
		                       <a class="btn btn-primary" href="{:U('Crm/addvisit',array('act'=>'edit','vis_id'=>$vo['id']))}"><i class="fa fa-pencil"></i></a>
		                       <a href="{:U('Admin/crm/detail',array('id'=>$vo['id']))}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="查看详情"><i class="fa fa-eye"></i></a>
		                      <a class="btn btn-danger" onclick="delfunc(this)" data-url="{:U('Crm/delHandle')}" data-id="{$vo.id}"><i class="fa fa-trash-o"></i></a>
				     </td>
		                   </tr>
		                  </foreach>
		                   </tbody>
		                 <tfoot>
		                 
		                 </tfoot>
		               </table>
	               </div>
	          </div>
              <div class="row">
              	    <div class="col-sm-6 text-left">
              	    	<button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>
              	    </div>
                    <div class="col-sm-6 text-right">{$page}</div>		
              </div>
	          </div>
	        </div>
       	</div>
       </div>
   </section>
<script>
$(document).ready(function(){
	$('#add_time').daterangepicker({
		format:"YYYY-MM-DD HH:mm",
		singleDatePicker: false,
		showDropdowns: true,
		minDate:'2021-01-01 00:00',
		maxDate:'2030-01-01 00:00',
		startDate:'{:date("Y-m-d")} 00:00',
        showWeekNumbers: true,
        timePicker: true,
        timePickerIncrement: 1,
        timePicker12Hour: false,
        opens: 'right',
        buttonClasses: ['btn btn-default'],
        applyClass: 'btn-small btn-primary',
        cancelClass: 'btn-small',
	    locale : {
            applyLabel : '确定',
            cancelLabel : '取消',
            fromLabel : '起始时间',
            toLabel : '结束时间',
            customRangeLabel : '自定义',
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
            firstDay : 1
        }
	});

	$("body").on("click", function() {
		$('#fenlei_box').hide(100);
	});
	$("#fenlei_box").on("click","li", function() {
		var user_id=$(this).attr('rel'),
		company=$(this).attr('title');

		$('#user_name').val(company);
		$('#user_id').val(user_id);
	});
})

	function user_sousuo(obj)
	{
	    var value = obj.val();
		if($.trim(user_name) == '')
			return false;
		
		var dai_type=$("input[type='radio']:checked").val();
	    $.ajax({
	       type : "POST",
	       url:"/index.php?m=admin&c=crm&a=search_user",//+tab,
	       data :{search_key:value},
	        success: function(data){
				data=JSON.parse(data);
					 if(data.code=='200'){
						$('#fenlei_box').show(200);
						$('#add_user').hide(100);
						$('#fenlei_box').html(data.selects);
					 }else{
						$('#fenlei_box').hide(100);
						if(dai_type==1)
						$('#add_user').show(200);
						
						$('#fenlei_box').html('');
					 }
	        }
	    });
	}
  
$("#daochu").click(function(){
	var user_id=$("#user_id").val(),
	user_name=$("#user_name").val(),
	visit_name=$("#visit_name").val(),
    timegap=$("#timegap").val();
	location.href='/index.php/Admin/crm/export_user?user_id='+user_id+'&user_name='+user_name+'&timegap='+timegap+'&visit_name='+visit_name;
});
</script>
</div>
</body>
</html>   
